<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:hr="http://java.sun.com/jsf/composite/autocomplete">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form >
                    <p:panel >
                        <f:facet name="header" >
                            <h:outputLabel value="Bill Session Report" />
                        </f:facet>
                        <p:panelGrid columns="2" >
                            <h:outputLabel value="From : " />
                            <p:calendar value="#{channelReportController.fromDate}" pattern="dd MMMM yyyy hh:mm:ss a" />
                            <h:outputLabel value="To : " />
                            <p:calendar value="#{channelReportController.toDate}" pattern="dd MMMM yyyy hh:mm:ss a" />
                            <h:outputLabel value="Specialtiy : "/>
                            <hr:completeSpeciality value="#{channelReportController.reportKeyWord.speciality}"/>
                            <h:outputLabel value="Staff : "/>
                            <hr:completeStaff value="#{channelReportController.reportKeyWord.staff}"/>
                            <h:outputLabel value="Agency : "/>
                            <hr:completeAgency value="#{channelReportController.reportKeyWord.institution}"/>                            
                        </p:panelGrid>
                        <p:commandButton ajax="false" value="Process Paid" action="#{channelReportController.createBillSession_report_1()}"/>
                        <p:commandButton ajax="false" value="Clear" action="#{channelReportController.makeNull()}"/>
                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" >
                            <pe:exporter type="xlsx" target="tb1,tb2,tb3,tb4" fileName="bill_session_report"  />
                        </p:commandButton>
                        <p:commandButton value="Print" ajax="false" action="#" >
                            <p:printer target="gpBillPreview" />
                        </p:commandButton>
                        <p:panel id="gpBillPreview" >                     
                            <p:dataTable value="#{channelReportController.billSessionsBilled}" id="tb1" var="bs">
                                <f:facet name="header">
                                    <h:outputLabel value="BILL SESSION"/>
                                    <h:outputLabel value="From : " style=" white-space:pre-line;"/>
                                    <h:outputLabel  value="#{channelReportController.fromDate}" >
                                        <f:convertDateTime pattern="dd MMM yyyy HH:mm a"/>
                                    </h:outputLabel>                          
                                    <h:outputLabel value="&emsp;&emsp;To :"/>
                                    <h:outputLabel  value="#{channelReportController.toDate}" >
                                        <f:convertDateTime pattern="dd MMM yyyy HH:mm a"/>
                                    </h:outputLabel>
                                    <h:outputLabel value="#{commonReport.department.name}"/>
                                    
                                </f:facet>
                                <p:column headerText="Booking ID">
                                    <h:outputLabel  value="#{bs.bill.bookingId}" />
                                </p:column>
                                <p:column headerText="Booking At">
                                    <h:outputLabel  value="#{bs.bill.createdAt}" />
                                </p:column>
                                <p:column headerText="Appointment At">
                                    <h:outputLabel  value="#{bs.bill.appointmentAt}" />
                                </p:column>
                                <p:column headerText="User">
                                    <h:outputLabel  value="#{bs.bill.creater.webUserPerson.nameWithTitle}" />
                                </p:column>
                                <p:column headerText="Person">
                                    <h:outputLabel  value="#{bs.bill.person.nameWithTitle}" />
                                </p:column>
                                <p:column headerText="Staff">
                                    <h:outputLabel  value="#{bs.staff.person.nameWithTitle}" />
                                </p:column>
                                <p:column headerText="Session Name">
                                    <h:outputLabel  value="#{bs.serviceSession.name}" />
                                </p:column>
                                <p:column headerText="Doctor Fee" styleClass="averageNumericColumn">
                                    <h:outputLabel  value="#{bs.billItem.staffFee}" />
                                </p:column>
                                <p:column headerText="Hospital Fee" styleClass="averageNumericColumn">
                                    <h:outputLabel  value="#{bs.billItem.hospitalFee}" />
                                </p:column>
                                <p:column headerText="Payment Method">
                                    <h:outputLabel  value="#{bs.bill.paymentMethod}" />
                                </p:column>
                                <p:column headerText="Status">
                                    <h:outputLabel value="Cancelled" rendered="#{bs.bill.cancelled}"/>
                                    <h:outputLabel value="Refunded" rendered="#{bs.bill.refunded}"/>
                                    <f:facet name="footer">
                                    <p:outputLabel value="#{channelReportController.netTotal}">
                                        <f:convertNumber pattern="#,###.##" />
                                    </p:outputLabel>
                                </f:facet>
                                </p:column>
                            </p:dataTable>

                            <p:dataTable value="#{channelReportController.billSessionsCancelled}" id="tb2" var="bs">
                                <p:column headerText="Booking ID">
                                    <h:outputLabel  value="#{bs.bill.bookingId}" />
                                </p:column>
                                <p:column headerText="Booking At">
                                    <h:outputLabel  value="#{bs.bill.createdAt}" />
                                </p:column>
                                <p:column headerText="Appointment At">
                                    <h:outputLabel  value="#{bs.bill.appointmentAt}" />
                                </p:column>
                                <p:column headerText="User">
                                    <h:outputLabel  value="#{bs.bill.creater.webUserPerson.nameWithTitle}" />
                                </p:column>
                                <p:column headerText="Person">
                                    <h:outputLabel  value="#{bs.bill.person.nameWithTitle}" />
                                </p:column>
                                <p:column headerText="Staff">
                                    <h:outputLabel  value="#{bs.staff.person.nameWithTitle}" />
                                </p:column>
                                <p:column headerText="Session Name">
                                    <h:outputLabel  value="#{bs.serviceSession.name}"/>
                                </p:column>
                                <p:column headerText="Doctor Fee" styleClass="averageNumericColumn">
                                    <h:outputLabel  value="#{bs.billItem.staffFee}"/>
                                </p:column>
                                <p:column headerText="Hospital Fee" styleClass="averageNumericColumn">
                                    <h:outputLabel  value="#{bs.billItem.hospitalFee}" />
                                </p:column>
                                <p:column headerText="Payment Method" styleClass="averageNumericColumn">
                                    <h:outputLabel  value="#{bs.bill.paymentMethod}" />
                                </p:column>
                                <p:column headerText="Status">
                                    <h:outputLabel value="Cancelled" rendered="#{bs.bill.cancelled}"/>
                                    <h:outputLabel value="Refunded" rendered="#{bs.bill.refunded}"/>
                                    <f:facet name="footer">
                                        <p:outputLabel value="#{channelReportController.cancelTotal}">
                                            <f:convertNumber pattern="#,###.##" />
                                        </p:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:dataTable>

                            <p:dataTable value="#{channelReportController.billSessionsReturn}" id="tb3" var="bs">
                                <p:column headerText="Booking ID">
                                    <h:outputLabel  value="#{bs.bill.bookingId}" />
                                </p:column>
                                <p:column headerText="Booking At">
                                    <h:outputLabel  value="#{bs.bill.createdAt}"/>
                                </p:column>
                                <p:column headerText="Appointment At">
                                    <h:outputLabel  value="#{bs.bill.appointmentAt}"/>
                                </p:column>
                                <p:column headerText="User">
                                    <h:outputLabel  value="#{bs.bill.creater.webUserPerson.nameWithTitle}"/>
                                </p:column>
                                <p:column headerText="Person">
                                    <h:outputLabel  value="#{bs.bill.person.nameWithTitle}"/>
                                </p:column>
                                <p:column headerText="Staff">
                                    <h:outputLabel  value="#{bs.staff.person.nameWithTitle}"/>
                                </p:column>
                                <p:column headerText="Session Name">
                                    <h:outputLabel  value="#{bs.serviceSession.name}"/>
                                </p:column>
                                <p:column headerText="Doctor Fee" styleClass="averageNumericColumn">
                                    <h:outputLabel  value="#{bs.billItem.staffFee}"/>
                                </p:column>
                                <p:column headerText="Hospital Fee" styleClass="averageNumericColumn">
                                    <h:outputLabel  value="#{bs.billItem.hospitalFee}"/>
                                </p:column>
                                <p:column headerText="Payment Method">
                                    <h:outputLabel  value="#{bs.bill.paymentMethod}"/>
                                </p:column>
                                <p:column headerText="Status">
                                    <h:outputLabel value="Cancelled" rendered="#{bs.bill.cancelled}"/>
                                    <h:outputLabel value="Refunded" rendered="#{bs.bill.refunded}"/>
                                    <f:facet name="footer">
                                        <p:outputLabel value="#{channelReportController.refundTotal}">
                                            <f:convertNumber pattern="#,###.##" />
                                        </p:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:dataTable>


                            <p:dataTable value="#{channelReportController.valueList}" id="tb4" var="ls">
                                <p:column headerText="BillType">
                                    <h:outputLabel  value="#{ls.string}"/>
                                </p:column>
                                <p:column headerText="Billed">
                                    <h:outputLabel  value="#{ls.value1}"/>
                                    <f:facet name="footer">
                                        <p:outputLabel value="#{channelReportController.totalBilled}">
                                            <f:convertNumber pattern="#,###" />
                                        </p:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column headerText="Cancelled">
                                    <h:outputLabel  value="#{ls.value2}"/>
                                    <f:facet name="footer">
                                        <p:outputLabel value="#{channelReportController.totalCancel}">
                                            <f:convertNumber pattern="#,###" />
                                        </p:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column headerText="Refund">
                                    <h:outputLabel  value="#{ls.value3}"/>
                                    <f:facet name="footer">
                                        <p:outputLabel value="#{channelReportController.totalRefund}">
                                            <f:convertNumber pattern="#,###" />
                                        </p:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <f:facet name="footer" >
                                    <h:outputLabel value="#{sessionController.loggedUser.webUserPerson.name}" style="float: right"/>
                                </f:facet>
                            </p:dataTable>
                        </p:panel>


                    </p:panel>

                </h:form>
            </ui:define>

        </ui:composition>

    </h:body>
</html>
